package com.wzx.ptplatform.controller.student;

import com.wzx.ptplatform.domain.CollectMessage;
import com.wzx.ptplatform.domain.StudentMessage;
import com.wzx.ptplatform.service.CollectMessageService;
import com.wzx.ptplatform.service.StudentMessageService;
import io.swagger.annotations.Api;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author wzx
 */
@Api(tags = "学生模块")
@RestController
public class StudentIndexController {

    final StudentMessageService studentMessageService;
    final CollectMessageService collectMessageService;

    public StudentIndexController(StudentMessageService studentMessageService, CollectMessageService collectMessageService) {
        this.studentMessageService = studentMessageService;
        this.collectMessageService = collectMessageService;
    }

    @GetMapping("student_index")
    public ModelAndView studentIndex() {
        return new ModelAndView("student/index");
    }

    @GetMapping("student_message_view")
    public ModelAndView studentMessageView(String id, Model model) {
        List<StudentMessage> studentMessageList = studentMessageService.findByStudentId(Long.parseLong(id));
        model.addAttribute("studentMessageList", studentMessageList);
        return new ModelAndView("student/message");
    }

    @GetMapping("student_collect_pt_message_view")
    public ModelAndView studentCollectPtMessageView(String id, Model model) {
        List<CollectMessage> collectMessageList = collectMessageService.findByStudentId(Long.parseLong(id));
        model.addAttribute("collectMessageList", collectMessageList);
        return new ModelAndView("student/collect");
    }
}
